﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using aerowan.common.Network;
using System.Windows;

namespace aerowan.pilot_client.Network.Packets
{
    class SCPkt_Login : BaseRemotePacket
    {
        public bool? Success;

        public SCPkt_Login(byte[] data)
            : base(data)
        {

        }

        public override void ReadPacket(NetConnection con)
        {
            byte b = this.ReadByte2();
            if (b == 0x00) Success = false;
            else if (b == 0x01) Success = true;
            else if (b == 0x12) Success = null;
            else Success = false;
        }

        public override void RunPacket(NetConnection con)
        {
            if (Success == false)
            {
                ApplicationContext.Instance.Connected = false;
                MessageBox.Show("Invalid Account ID or Password.");
            }
            else if (Success == null)
            {
                ApplicationContext.Instance.Connected = false;
                MessageBox.Show("Callsign already in use.");
            }
            else
            {
                ApplicationContext.Instance.Connected = true;
            }
        }
    }
}
